$(function (){
   $('.orderButton').on('click',function (){
       $('.tab-pay').show();
       $('.tab-pay').hide().each(function (index){
           $(this).delay(200*index).fadeIn(800);
       });
   });

    $('#bye').on('click',function (){
        $('.tab-pay').hide();
    });

    $('#victory').on('click',function (){
        var btn = $('input:radio:checked');
        var address = btn.val();
        $.ajax({
            data: {
                address: address,
            },
            type: 'POST',
            url: 'http://localhost:8080/mypetstore/OrderJS',
            success: function (data) {
                $('#orderForm').remove();
                $('.tab-pay').append('<h1>Successfully Paid</h1>');
            },
            error: function (errorMsg) {
                console.log(errorMsg);
            }
        });
    });

});